<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdn.bootcdn.net/ajax/libs/qs/6.10.1/qs.min.js"></script>
  <script src="./7-utils.js"></script>
  <title>Document</title>
  <script>
    var url = 'https://api.muxiaoguo.cn/api/lajifl'
    var data = {
      m:'易拉罐'
    }
    get(url,data,function(res) {
      // 将JSON字符串转成普通对象
      console.log(JSON.parse(res));
      var resp = JSON.parse(res)
      // 将后台请求回来的数据，生成dom节点，并且加载到页面上
      var dom = document.getElementsByTagName('div')[0]
      dom.innerText = resp.data.description.Release_requirement
    },function(res) {
      console.log(res);
    });
    // 调用utils中的post方法
    var loginUrl = 'http://47.94.46.113:7788/user/login'
    var loginData = {
      username: 'admin1',
      password: '123321'
    } 
    post(loginUrl, JSON.stringify(loginData), 'application/json', function(res){
      // 将login接口返回的token秘钥赋值给token变量
      var token = JSON.parse(res).data.token
      // 请求消息的findAll接口
      var articleUrl = 'http://47.94.46.113:7788/article/findAll'
      get(articleUrl, null, function(res) {
        console.log(res);
      }, function(res) {}, token)
    }, function(res) {})
  </script>
</head>
<body>
  <div class="box"></div>
</body>
</html>